package com.hspedu.homework;

import java.util.TreeSet;

/**
 * @author LiuJinTao
 * @className HomeWork04
 * @date 2024/06/14 12:53
 * @description TODO
 */
public class HomeWork04 {
    public static void main(String[] args) {
        TreeSet treeSet = new TreeSet();
        // TreeSet() 没有传入 Comparator 接口的匿名内部类
        // 所以在底层 Comparable<? super K> k = (Comparable<? super K>) key;
        // 报错 Person 无法转成 Comparable<? super K>
        treeSet.add(new Person());// ClassCastException
        System.out.println("treeSet=" + treeSet);
    }
}
class Person implements Comparable{
    @Override
    public int compareTo(Object o) {
        return 0;
    }

    @Override
    public String toString() {
        return "Person{}";
    }
}